<?php
//APP
function getAccountStats($id)
//ok
{
	$tables = array();
	$tables[0] = 'core_accounts';
	
	$fields = array();
	$fields[0] = 'dateMade';
	$fields[1] = 'dateUpdated';
	$fields[2] = 'updatedBy';
	$fields[3] = 'accountType';
	
	$whereClause = 'accountID = "'.$id.'"';
	
	$data = SQLRecover($tables, $fields, $whereClause);
	$ret = array();
	
	if($data['queryStatus'] == 'DB Query success!')
	{
		$ret['accountType'] = $data['accountType'][0];
		$ret['updatedBy'] = $data['updatedBy'][0];
		$ret['created'] = $data['dateMade'][0];
		$ret['updated'] = $data['dateUpdated'][0];
	}
	else
	{
		$ret['accountType'] = 'N/A';
		$ret['updatedBy'] = 'N/A';
		$ret['created'] = 'N/A';
		$ret['updated'] = 'N/A';
	}
		
	return $ret;
}

function getAccountAttributes($id)
//ok
{
	$tables = array();
	$tables[0] = 'core_accounts_contacts';
	
	$fields = array();
	$fields[0] = 'type';
	$fields[1] = 'detail';
	$fields[2] = 'priority';
	$fields[3] = 'contactID';
	
	$whereClause = 'accountID="'.$id.'" AND priority > 0 ORDER BY priority ASC';
	
	$data = SQLRecover($tables, $fields, $whereClause);
	
	if($data['queryStatus'] == 'DB Query success!')
	{
		$data['rowSize'] = sizeOf($data['detail']);
	}
	else
	{
		$data['rowSize'] = 0;
		$data['type'][0] = 'N/A';
		$data['detail'][0] = 'N/A';
		$data['contactID'][0] = 'N/A';
		$data['priority'][0] = 'N/A';
	}
	return $data;
}

function getProfileAttributes($id)
//ok
{
	$output = array();
	$tables = array();
	$tables[0] = 'core_accounts_contacts';
	
	$fields = array();
	$fields[0] = 'detail';
	
	$whereClause = '(type = "_name" OR type = "_notes") AND accountID = "'.$id.'" ORDER BY type ASC';
	
	$data = SQLRecover($tables, $fields, $whereClause);

	$output['name'] = $data['detail'][0];
	$output['notes'] = $data['detail'][1];
	return $output;
}

function getAccountAddresses($id)
//ok
{
	$tables = array();
	$tables[0] = 'core_accounts_contacts';
	
	$fields = array();
	$fields[0] = 'type';
	$fields[1] = 'detail';
	$fields[2] = 'priority';
	$fields[3] = 'contactID';
	
	$whereClause = 'accountID="'.$id.'" AND type = "_address" ORDER BY priority DESC';
	
	$data = SQLRecover($tables, $fields, $whereClause);
	
	$data['rowSize'] = sizeOf($data['detail']) - 1;
	$data['mainAddress'] = $data['detail'][0];
	
	if($data['rowSize'] >= 1)
	{
		for ($i=1; $i<sizeOf($data['detail']); $i++)
		{
			$j = $i-1;
			$data['auxID'][$j] = $data['contactID'][$i];
			$data['auxAddress'][$j] = $data['detail'][$i];
			$data['auxPriority'][$j] = $data['priority'][$i];
		}
	}
	else
	{
		$data['auxAddress'][0] = 'noAddress';
	}
		
	return $data;
}

function getNewClientID($name)
{
	$tables = array();
	$tables[0] = 'core_accounts a';
	$tables[1] = 'core_accounts_contacts c';
	
	$fields = array();
	$fields[0] = 'a.accountID id';
	
	$whereClause = 'a.accountID = c.accountID AND c.type="_name" AND c.detail = "'.$name.'"';
	
	$data = SQLRecover($tables, $fields, $whereClause);
	
	return $data['id'][0];
}
function generateNewAccount($post)
{
	$tableName = 'core_accounts';
	
	$fields = array();
	$fields[0] = 'accountType';
	$fields[1] = 'dateMade';
	$fields[2] = 'dateUpdated';
	$fields[3] = 'updatedBy';
	
	$values = array();
	$values[0] = $post['type'];
	$values[1] = sqlDateNow();
	$values[2] = sqlDateNow();
	$values[3] = $_SESSION['user'];
	
	$data = SQLInsert($tableName, $fields, $values);
	
	$tables = array();
	$tables[0] = 'core_accounts';
	
	$fields = array();
	$fields[0] = 'accountID';
	
	$whereClause = 'accountID > 1 ORDER BY accountID DESC';
	
	$high = SQLRecover($tables, $fields, $whereClause);
	
	$tableName = 'core_accounts_contacts';
	
	$fields = array();
	$fields[0] = 'type';
	$fields[1] = 'detail';
	$fields[2] = 'priority';
	$fields[3] = 'dateCreated';
	$fields[4] = 'accountID';
	
	$values = array();
	$values[0] = '_name';
	$values[1] = $post['clientName'];
	$values[2] = '0';
	$values[3] = sqlDateNow();
	$values[4] = $high['accountID'][0];
	
	$data = SQLInsert($tableName, $fields, $values);
	
	$tableName = 'core_accounts_contacts';
	
	$fields = array();
	$fields[0] = 'type';
	$fields[1] = 'detail';
	$fields[2] = 'priority';
	$fields[3] = 'dateCreated';
	$fields[4] = 'accountID';
	
	$values = array();
	$values[0] = '_address';
	$values[1] = $post['mainAdd'];
	$values[2] = '0';
	$values[3] = sqlDateNow();
	$values[4] = $high['accountID'][0];
	
	$data = SQLInsert($tableName, $fields, $values);
	
	$tableName = 'core_accounts_contacts';
	
	$fields = array();
	$fields[0] = 'type';
	$fields[1] = 'detail';
	$fields[2] = 'priority';
	$fields[3] = 'dateCreated';
	$fields[4] = 'accountID';
	
	$values = array();
	$values[0] = '_notes';
	$values[1] = $post['notes'];
	$values[2] = '0';
	$values[3] = sqlDateNow();
	$values[4] = $high['accountID'][0];
	
	$data = SQLInsert($tableName, $fields, $values);
}

function nameOK($name)
{
	$tables = array();
	$tables[0] = 'core_accounts_contacts';
	
	$fields = array();
	$fields[0] = 'accountID';
	
	$whereClause = 'type="_name" AND detail="'.$name.'"';
	
	$data = SQLRecover($tables, $fields, $whereClause);
	
	return ($data['queryStatus'] == 'DB Query success!' ? false : true);
}
function getForm($value, $msg)
{
	$value['clientName'] = (isset($value['clientName']) ? $value['clientName'] : '');
	$value['type'] = (isset($value['type']) ? $value['type'] : '');
	$value['mainAdd'] = (isset($value['mainAdd']) ? $value['mainAdd'] : '');
	$value['notes'] = (isset($value['notes']) ? $value['notes'] : '');

	if($value['type'] == 'mixed')
	{
		$options = '<option value="'.get('type').'">'.ucwords(get('type')).'</option>
			<option value="mixed" selected>Mixed</option>';
	}
	else
	{
		$options = '<option value="'.get('type').'" selected>'.ucwords(get('type')).'</option>
			<option value="mixed">Mixed</option>';
	}
	
	return '
	<form method="POST" action="index.php?page=control&sector=accounts&act=new&type='.get('type').'&sub=yes">
	<div id="actCMS" class="grid_12 mainBox bordered" rel="'.$msg.'">
		<h1>Create New '.ucwords(get('type')).' Account</h1><br />
		
		<div class="grid_3 alpha">
		<h2>'.ucwords(get('type')).' Name:</h2><br />
		<input type="text" id="clientName" name="clientName" class="mainClass" value="'.$value['clientName'].'" /><br />
		</div>
		<div class="grid_9 omega">
		<h2>'.ucwords(get('type')).' Account Type:</h2><br />
		<select name="type" class="mainClass">
			'.$options.'
		</select>
		</div>
		<div class="clear">
		<!--spanner-->
		</div>
		<div class="grid_12 alpha">
		<h2>Main Address</h2><br />
		<textarea name="mainAdd" class="mainAdd">'.$value['mainAdd'].'</textarea><br />
		<h2>Notes</h2><br />
		<textarea name="notes" class="mainNotes" >'.$value['notes'].'</textarea>
		</div>
	</div>
	<div class="grid_12 mainBox">
		<div class="grid_6 alpha centerAlign">
			<input type="submit" class="buttons" value="Save"/>
		</div>
		<div class="grid_6 omega">
			&nbsp;
		</div>
	</div>
	</form>';
}

function getEditForm($value, $msg, $attributes)
{

	$value['clientName'] = (isset($value['clientName']) ? $value['clientName'] : '');
	$value['type'] = (isset($value['type']) ? $value['type'] : '');
	$value['mainAdd'] = (isset($value['mainAdd']) ? $value['mainAdd'] : '');
	$value['notes'] = (isset($value['notes']) ? $value['notes'] : '');
	
	if($value['type'] == 'mixed')
	{
		$options = '<option value="'.get('type').'">'.ucwords(get('type')).'</option>
			<option value="mixed" selected>Mixed</option>';
	}
	else
	{
		$options = '<option value="'.get('type').'" selected>'.ucwords(get('type')).'</option>
			<option value="mixed">Mixed</option>';
	}
	
	//-------LIST OF ADDRESSES -- iteration of existing entries
	$addressList = '';
	$addressPri = '';
	$addressDel = '';
	
	if($attributes['addresses']['detail'][0] != 'noAddress')
	{
		for ($i=0; $i<$attributes['addresses']['rows']; $i++)
		{
			$addressList .= '<br /><input type="hidden" name="existAddID[]" value="'.$attributes['addresses']['id'][$i].'" /><input type="text" class="existingAdd formver" name="existAdd[]" value="'.$attributes['addresses']['detail'][$i].'"/>
			';
			
			$pri = $attributes['addresses']['priority'][$i] * -1;
			$addressPri .= '<br /><input type="text" class="existingAddPri formver numOnly" name="existAddPri[]" value="'.$pri.'" />';
			
			$addressDel .= '<br /><input type="checkbox" class="existingAddDel" name="existAddDel[]" value="'.$attributes['addresses']['id'][$i].'" />';	
		}
	}
	//-------LIST OF MISC DETAILS -- iteration of existing entries
	
	/*
	$attributes['addresses']['detail'] = $addresses['auxAddress'];
	$attributes['addresses']['priority'] = $addresses['auxAddress'];
	$attributes['addresses']['rows'] = $addresses['rowSize'];
	$attributes['addresses']['id'] = $addresses['auxID'];
	
	$attributes['misc']['type'] = $mainAttributes['type'];
	$attributes['misc']['detail'] = $mainAttributes['detail'];
	$attributes['misc']['priority'] = $mainAttributes['priority'];
	$attributes['misc']['id'] = $mainAttributes['contactID'];
	$attributes['misc']['rows'] = $mainAttributes['rowSize'];
	*/
	
	$miscDel = '&nbsp;';
	$miscType = '&nbsp;';
	$miscDetail = '&nbsp;';
	$miscPri = '&nbsp;';
	
	if($attributes['misc']['rows'] > 0)
	{
		$miscDel = '';
		$miscType = '';
		$miscDetail = '';
		$miscPri = '';
		for ($i=0; $i<$attributes['misc']['rows']; $i++)
		{
			$miscDetail .= '<br /><input type="hidden" name="existMiscID[]" value="'.$attributes['misc']['id'][$i].'" /><input type="text" class="existingMisc formver" name="existMisc[]" value="'.$attributes['misc']['detail'][$i].'"/>';
			
			$miscType .= '<br /><input type="text" class="existingMiscType formver" name="existMiscType[]" value="'.$attributes['misc']['type'][$i].'"/>';
			
			$miscPri .= '<br /><input type="text" class="existingMiscPri formver numOnly" name="existMiscPri[]" value="'.$attributes['misc']['priority'][$i].'"/>';
			
			$miscDel .= '<br /><input type="checkbox" class="existingMiscDel formver" name="existMiscDel[]" value="'.$attributes['misc']['id'][$i].'" />';
		}
	}
	
	return '
	<form method="POST" id="editFrm" action="index.php?page=control&sector=accounts&act=upd&type='.get('type').'&sub=yes&entry='.get('entry').'" class="inline">
	<div id="actCMS" class="grid_12 mainBox bordered modDIV" rel="'.$msg.'">
		<h1>Edit '.ucwords(get('type')).' Account</h1><br />
		<div id="modProfile" class="formA">
			<div class="grid_3 alpha">
			<h2>'.ucwords(get('type')).' Name:</h2><br />
			<input type="text" id="clientName" name="clientName" class="mainClass formver" value="'.$value['clientName'].'" /><br />
			</div>
			<div class="grid_9 omega">
			<h2>'.ucwords(get('type')).' Account Type:</h2><br />
			<select name="type" class="mainClass">
				'.$options.'
			</select>
			</div>
			<div class="clear">
			<!--spanner-->
			</div>
			<div class="grid_12 alpha">
			<h2>Main Address</h2><br />
			<textarea name="mainAdd" class="mainAdd formver">'.$value['mainAdd'].'</textarea><br />
			<h2>Notes</h2><br />
			<textarea name="notes" class="mainNotes formver">'.$value['notes'].'</textarea>
			</div>
		</div>
		<div id="modDetails" class="formA">
			<h2>Other Addresses</h2><br />
			<div class="grid_6 alpha addressDiv">
				<div class="clear">
				<!--spanner-->
				</div>
				<div id="delGridAdd" class="grid_1 alpha centerAlign">
					<b>Delete:</b>
					'.$addressDel.'
				</div>
				<div id="listGridAdd" class="grid_3">
					<b>Address:</b>
					'.$addressList.'
				</div>
				<div id="priGridAdd" class="grid_1 omega">
					<b>Order:</b>
					'.$addressPri.'
				</div>
				
				<div class="clear">
				<!--spanner-->
				</div>
			</div>
			<div class="clear">
			<!--spanner-->
			</div>
			<h2>Account Details</h2><br />
				<div class="clear">
				<!--spanner-->
				</div>
			<div class="grid_6 alpha detailDiv">
				<div id="delGridMisc" class="grid_1 alpha centerAlign">
					<b>Delete:</b>
					'.$miscDel.'
				</div>
				<div id="typeGridMisc" class="grid_1">
					<b>Type:</b>
					'.$miscType.'
				</div>
				<div id="detailGridMisc" class="grid_2">
					<b>Contact Detail:</b>
					'.$miscDetail.'
				</div>
				<div id="priGridMisc" class="grid_1 omega">
					<b>Order:</b>
					'.$miscPri.'
				</div>
			</div>
			<img src="./img/global/plus.png" alt="plus" width="20" height="20" class="plus" id="addAddress" />
			<img src="./img/global/plus.png" alt="plus" width="20" height="20" class="plus" id="addDetail" />
		</div>
	</div>
	<div class="grid_12 mainBox">
		<div class="grid_6 alpha centerAlign">
			<input type="submit" class="buttons" value="Save"/></form><input id="modUpdateDtails" type="button" class="buttons" value="Edit Account Details" /><input id="deleteAcct" type="button" class="buttons" value="Delete" alt="'.get('type').'" rel="'.get('entry').'">
		</div>
		<div class="grid_6 omega">
			&nbsp;
		</div>
	</div>
	';
}

if(get('act') == 'new')
{
	if(get('sub') == 'yes')
	{
		$nameOK = (post('clientName') == 'null' || post('type') == 'null' || post('mainAdd') == 'null' || post('notes') == 'null' ? false : true);
		
		if($nameOK)
		{
			//INSERT
			generateNewAccount($_POST);
			$display = '<div class="grid_12 mainBox">
				<h1>Create New '.ucwords(get('type')).' Account</h1>
				<p>A new account has been successfully created. Click <a href="#" title="'.INDEX.'accounts'.EXT.'type='.get('type').'&entry='.getNewClientID(post('clientName')).'" id="closeWin" onclick="'.jsClose().'" >here</a> to close this window.</p>
			</div>';
		}
		else
		{
			$display = getForm($_POST, 'All fields are required to be filled in.');
		}
	}
	else
	{
		$display = getForm($_POST, '');
	}
}

else if(get('act') == 'upd' && get('entry') != 'null')
{
	if(get('sub') == 'yes')
	{
		//NOTE: multiply address priority by -1 before encoding.
		$nameOK = true;
		if(post('clientName') == 'null' || post('type') == 'null' || post('mainAdd') == 'null' || post('notes') == 'null')
		{
			$nameOK = false;
		}
		$display = '';
		if($nameOK)
		{
			//update script: profile.
			$tableName = 'core_accounts';
			
			$fields = array();
			$fields[0] = 'accountType';
			$fields[1] = 'dateUpdated';
			$fields[2] = 'updatedBy';
			
			$values = array();
			$values[0] = post('type');
			$values[1] = sqlDateNow();
			$values[2] = $_SESSION['user'];
			
			$whereClause = 'accountID = "'.get('entry').'"';
			
			$data = SQLUpdate($tableName, $whereClause, $fields, $values);
			//-----
			
			//update script: _name.
			if(post('clientName') != '')
			{
				$tableName = 'core_accounts_contacts';
				
				$fields = array();
				$fields[0] = 'detail';
				
				$values = array();
				$values[0] = post('clientName');
				
				$whereClause = 'type="_name" AND accountID="'.get('entry').'"';
				
				$data = SQLUpdate($tableName, $whereClause, $fields, $values);
			}
			//-----
			
			//update script: _notes.
			$tableName = 'core_accounts_contacts';
			
			$fields = array();
			$fields[0] = 'detail';
			
			$values = array();
			$values[0] = post('notes');
			
			$whereClause = 'type="_notes" AND accountID="'.get('entry').'"';
			
			$data = SQLUpdate($tableName, $whereClause, $fields, $values);
			//-----
			
			//update script: _address - main.
			$tableName = 'core_accounts_contacts';
			
			$fields = array();
			$fields[0] = 'detail';
			
			$values = array();
			$values[0] = post('mainAdd');
			
			$whereClause = 'type="_address" AND accountID="'.get('entry').'" AND priority = "0"';
			
			$data = SQLUpdate($tableName, $whereClause, $fields, $values);
			//-----
			
			//update script: _address - aux.
			if(isset($_POST['existAddID']))
			{
				for ($i=0; $i<sizeOf($_POST['existAddID']); $i++)
				{
					if($_POST['existAdd'][$i] != '' && ($_POST['existAddPri'][$i] != '' || $_POST['existAddPri'][$i] != 0))
					{
						$tableName = 'core_accounts_contacts';
						
						$fields = array();
						$fields[0] = 'detail';
						$fields[1] = 'priority';
						
						$setPri = $_POST['existAddPri'][$i] * - 1 ;
						$values = array();
						$values[0] = $_POST['existAdd'][$i];
						$values[1] = $setPri;
						
						$whereClause = 'contactID = "'.$_POST['existAddID'][$i].'"';
						
						$data = SQLUpdate($tableName, $whereClause, $fields, $values);
					}
				}
				
					//>> delete script for marked entries
				if(isset($_POST['existAddDel']))
				{
					for ($i=0; $i<sizeOf($_POST['existAddDel']); $i++)
					{
						$data = SQLDelete ('core_accounts_contacts', 'contactID = "'.$_POST['existAddDel'][$i].'"');
					}
				}
			}
			//-----
			
			//update script: misc details
			if(isset($_POST['existMiscID']))
			{
				for ($i=0; $i<sizeOf($_POST['existMiscID']); $i++)
				{
					$tableName = 'core_accounts_contacts';
					
					$fields = array();
					$fields[0] = 'detail';
					$fields[1] = 'priority';
					$fields[2] = 'type';
					
					$values = array();
					$values[0] = $_POST['existMisc'][$i];
					$values[1] = $_POST['existMiscPri'][$i];
					$values[2] = $_POST['existMiscType'][$i];
					
					$whereClause = 'contactID="'.$_POST['existMiscID'][$i].'"';
					
					$data = SQLUpdate($tableName, $whereClause, $fields, $values);
				}
				
					//>> delete script for marked entries
				if(isset($_POST['existMiscDel']))
				{
					for ($i=0; $i<sizeOf($_POST['existMiscDel']); $i++)
					{
						$data = SQLDelete ('core_accounts_contacts', 'contactID = "'.$_POST['existMiscDel'][$i].'"');
					}
				}
			}
			//-----
			
			//insert script: addresses
			if(isset($_POST['newAdd']))
			{
				for ($i=0; $i<sizeOf($_POST['newAdd']); $i++)
				{
					if($_POST['newAdd'][$i] != '' && ($_POST['newAddPri'][$i] != '' || $_POST['newAddPri'][$i] != 0))
					{
						//get('entry')
						
						$prioritize = $_POST['newAddPri'][$i] * - 1; 
						
						$tableName = 'core_accounts_contacts';
						
						$fields = array();
						$fields[0] = 'type';
						$fields[1] = 'detail';
						$fields[2] = 'priority';
						$fields[3] = 'dateCreated';
						$fields[4] = 'accountID';
												
						$values = array();
						$values[0] = '_address';
						$values[1] = strip_tags($_POST['newAdd'][$i]);
						$values[2] = $prioritize;
						$values[3] = sqlDateNow();
						$values[4] = get('entry');
						
						$data = SQLInsert($tableName, $fields, $values);
					}	
				}
			}
			if(isset($_POST['newMiscType']))
			{
				for ($i=0; $i<sizeOf($_POST['newMiscType']); $i++)
				{
					if($_POST['newMiscType'][$i] != '' && $_POST['newMisc'][$i] != '' && $_POST['newMiscPri'][$i] != '')
					{
						
						$tableName = 'core_accounts_contacts';
						
						$fields = array();
						$fields[0] = 'type';
						$fields[1] = 'detail';
						$fields[2] = 'priority';
						$fields[3] = 'dateCreated';
						$fields[4] = 'accountID';
						
						$values = array();
						$values[0] = strip_tags($_POST['newMiscType'][$i]);
						$values[1] = strip_tags($_POST['newMisc'][$i]);
						$values[2] = $_POST['newMiscPri'][$i];
						$values[3] = sqlDateNow();
						$values[4] = get('entry');
						
						$data = SQLInsert($tableName, $fields, $values);
					}
				}
			}
			//-----
			
		}
		
		$accountStats = getAccountStats(get('entry'));
		$mainAttributes = getAccountAttributes(get('entry'));
		$addresses = getAccountAddresses(get('entry'));
		$accountProfile = getProfileAttributes(get('entry'));
		
		$data = array();
		$data['clientName'] = $accountProfile['name'];
		$data['type'] = $accountStats['accountType'];
		$data['mainAdd'] = $addresses['mainAddress'];
		$data['notes'] = $accountProfile['notes'];
		
		$attributes = array();
		$attributes['addresses']['detail'] = $addresses['auxAddress'];
		$attributes['addresses']['priority'] = (isset($addresses['auxPriority']) ? $addresses['auxPriority'] : 'x');
		$attributes['addresses']['rows'] = $addresses['rowSize'];
		$attributes['addresses']['id'] = (isset($addresses['auxID']) ? $addresses['auxID'] : 'x');
		
		$attributes['misc']['type'] = $mainAttributes['type'];
		$attributes['misc']['detail'] = $mainAttributes['detail'];
		$attributes['misc']['priority'] = $mainAttributes['priority'];
		$attributes['misc']['id'] = $mainAttributes['contactID'];
		$attributes['misc']['rows'] = $mainAttributes['rowSize'];
		$display = getEditForm($data, 'Your records have been updated successfully. Click <a href=\'_\' title=\'http://localhost/site_inventory/index.php?page=accounts&type='.get('type').'&entry='.get('entry').'\' onClick='.jsClose().'>here</a> to go back.', $attributes);
	}
	else
	{
		$accountStats = getAccountStats(get('entry'));
		$mainAttributes = getAccountAttributes(get('entry'));
		$addresses = getAccountAddresses(get('entry'));
		$accountProfile = getProfileAttributes(get('entry'));
		
		$data = array();
		$data['clientName'] = $accountProfile['name'];
		$data['type'] = $accountStats['accountType'];
		$data['mainAdd'] = $addresses['mainAddress'];
		$data['notes'] = $accountProfile['notes'];
		
		$attributes = array();
		$attributes['addresses']['detail'] = $addresses['auxAddress'];
		$attributes['addresses']['priority'] = (isset($addresses['auxPriority']) ? $addresses['auxPriority'] : 'x');
		$attributes['addresses']['rows'] = $addresses['rowSize'];
		$attributes['addresses']['id'] = (isset($addresses['auxID']) ? $addresses['auxID'] : 'x');
		
		$attributes['misc']['type'] = $mainAttributes['type'];
		$attributes['misc']['detail'] = $mainAttributes['detail'];
		$attributes['misc']['priority'] = $mainAttributes['priority'];
		$attributes['misc']['id'] = $mainAttributes['contactID'];
		$attributes['misc']['rows'] = $mainAttributes['rowSize'];
		
		$display = getEditForm($data, '', $attributes);
	}
}
else
{

	$display = '';
}
?>